<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGroupBuysTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('group_buys', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->string('intro', 500)->nullable();
            $table->timestamp('started_at')->nullable();
            $table->timestamp('ended_at')->nullable();
            $table->integer('goods_id');
            $table->string('goods_name');
            $table->decimal('goods_price')->default(0);
            $table->string('goods_thumb', 255);
            $table->decimal('price')->default(0);
            $table->integer('goods_num')->default(0);
            $table->integer('buy_num')->default(0);
            $table->integer('virtual_num')->default(0);
            $table->decimal('rebate', 10, 1);
            $table->integer('views')->default(0);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('group_buys');
    }
}
